Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wordpress/keycodes

Package Overview
Dependencies
Maintainers
21
Versions
172
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/keycodes

Keycodes utilities for WordPress. Used to check for keyboard events across browsers/operating systems.

  • 2.19.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
148K
increased by22.45%
Maintainers
21
Weekly downloads
 
Created

What is @wordpress/keycodes?

@wordpress/keycodes is a utility package that provides constants and helper functions for working with keyboard key codes. It is particularly useful for handling keyboard events in a consistent manner across different browsers and environments.

What are @wordpress/keycodes's main functionalities?

Keycode Constants

The package provides constants for common key codes, making it easier to reference and use them in your code without having to remember the numeric values.

const { ENTER, ESCAPE } = require('@wordpress/keycodes');
console.log(ENTER); // Outputs: 13
console.log(ESCAPE); // Outputs: 27

isKeyboardEvent

This helper function checks if a given keyboard event matches a specified key. It simplifies the process of handling specific key events.

const { isKeyboardEvent } = require('@wordpress/keycodes');
const event = new KeyboardEvent('keydown', { keyCode: 13 });
console.log(isKeyboardEvent(event, 'enter')); // Outputs: true

getKeycodeByKey

This function returns the keycode for a given key name, providing a convenient way to map key names to their corresponding key codes.

const { getKeycodeByKey } = require('@wordpress/keycodes');
console.log(getKeycodeByKey('Enter')); // Outputs: 13

Other packages similar to @wordpress/keycodes

Keywords

FAQs

Package last updated on 29 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc